<!DOCTYPE html>
<html>
  <head>
    <script>
var loc = location.href;

// Blockly files moved from /blockly to /static on 5 Dec 2012.
if (loc.match('/blockly/')) {
  loc = loc.replace('/blockly/', '/static/');
}

// Maze and Turtle moved from demos to apps on 29 Dec 2012.
if (loc.match(/\/demos\/(maze|turtle)\//)) {
  loc = loc.replace('/demos/', '/apps/');
}

// Vietnamese apps moved from vn to vi on 9 Jun 2012.
if (loc.match('/vn.html')) {
  loc = loc.replace('/vn.html', '/vi.html');
}

if (loc.match('/code/code.html')) {
  // Code moved to index.html on 7 Aug 2013.
  loc = loc.replace('/code.html', '/index.html');
} else if (loc.match('/apps/code/zh_tw.html')) {
  // zh-tw was changed to zh-hans on 25 Nov 2013.
  loc = loc.replace('/zh_tw.html', '/index.html?lang=zh-hans');
} else if (loc.match('/apps/code/index.html')) {
  // NOP.
} else if (loc.match(/\/apps\/code\/[-a-z]+\.html/)) {
  // Code became language-agnostic on 20 Jul 2013.
  loc = loc.replace(/\/([-a-z]+)\.html/, '/index.html?lang=$1');
}

if (loc.match('/apps/plane/plane.html')) {
  // Plane moved to index.html on 7 Aug 2013.
  loc = loc.replace('/plane.html', '/index.html');
} else if (loc.match('/apps/code/plane.html')) {
  // NOP.
} else if (loc.match(/\/apps\/plane\/[\d_]*[-a-z]+\.html/)) {
  // Plane became language-agnostic on 20 Jul 2013.
  loc = loc.replace('vn.html', 'vi.html');
  if (location.search) {
    loc = loc.replace(/\/[\d_]*([-a-z]+)\.html\?/, '/index.html?lang=$1&');
  } else {
    loc = loc.replace(/\/[\d_]*([-a-z]+)\.html/, '/index.html?lang=$1');
  }
}

if (loc.match('/apps/puzzle/')) {
  // Puzzle moved to Blockly Games on 15 Oct 2014.
  loc = 'https://blockly-games.appspot.com/puzzle';
} else if (loc.match('/apps/maze/')) {
  // Maze moved to Blockly Games on 10 Nov 2014.
  loc = 'https://blockly-games.appspot.com/maze';
} else if (loc.match('/apps/turtle/')) {
  // Turtle moved to Blockly Games on 10 Nov 2014.
  loc = 'https://blockly-games.appspot.com/turtle';
} else if (loc.match('/apps/')) {
  // Remaining apps moved to demos on 20 Nov 2014.
  loc = loc.replace('/apps/', '/demos/');
}

location = loc;

    </script>
  </head>
</html>
